"""drf_test URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import url,include
from rest_framework import routers
from tutorial.quickstart.views import *
import tutorial.auth01.views as auth01
import tutorial.permission02.views as permission02
import tutorial.serializer06.views as serializer06
import tutorial.view07.views as view07


# router=routers.DefaultRouter()
# # router.register(r'api_viewset',auth01.UserApiViewSet.as_view({'get': 'list'}))
# router.register(r'group',views.GroupViewSet)


#1、若不是通配使用，需要使用^ $,避免URL分发错误
urlpatterns = [
    path('admin/', admin.site.urls),
    # url(r"^",include((router.urls))),
    # url(r"^api_view$",auth01.UserApiView.as_view(),name="app"),
    url(r"^auth01/auth$",auth01.AuthView.as_view()),
    url(r"^auth01/order$",auth01.OrderView.as_view()),

    url(r"^permission02/auth", permission02.AuthView.as_view()),
    url(r"^permission02/order", permission02.OrderView.as_view()),

    url(r'^serializer06/roleview$', serializer06.RoleView.as_view()),  # 序列化：基础用法
    url(r'^serializer06/userview$', serializer06.UserinfoView.as_view()),  # 序列化：多对多用法
    url(r'^serializer06/roleview/custom$', serializer06.UserinfoView_Custom.as_view()),  # 序列化：自定义字段显示
    url(r'^serializer06/roleview/depth$', serializer06.UserinfoView_Custom.as_view()),  # 序列化：深度控制
    url(r'^serializer06/group/(?P<xxx>\d+)', serializer06.GroupView.as_view(),name='gp'),  #
    url(r'^serializer06/roleview/hyper$', serializer06.UserinfoView_Hyper.as_view()),  # 序列化：超链接控制

    url(r'^view07/api$', view07.UserView_API.as_view()),  # 序列化：超链接控制
    url(r'^view07/generic$', view07.UserView_Set.as_view({'get':'show','post':'create'})),  # 序列化：超链接控制
    url(r'^view07/viewset/(?P<pk>\d+)$', view07.UserView_Model.as_view({'get':'retrieve','delete':'destroy','post':'create','put':'update','patch':'partial_update'})),  # 序列化：超链接控制

]

